<?php
$path	= getEnv( 'REQUEST_URI' );
$uri	= getEnv( 'DOCUMENT_ROOT' ).$path;
$host	= getEnv( 'HTTP_HOST' );

header( 'HTTP/1.0 404 Not Found' );
if( !file_exists( $uri ) )
	die( "<h1>404 Not Found</h1>Invalid path: ".$path );

$folders	= array();
foreach( new DirectoryIterator( $uri ) as $entry )
	if( $entry->isDir() && strpos( $entry->getFilename(), "." ) !== 0 )
		$folders[$entry->getPathname()] = $entry->getFilename();
natcasesort( $folders );

$files	= array();
foreach( new DirectoryIterator( $uri ) as $entry )
	if( !$entry->isDir() && strpos( $entry->getFilename(), "." ) !== 0 )
		$files[$entry->getPathname()] = $entry->getFilename();
natcasesort( $files );

$style	= file_get_contents( dirname( __FILE__ ).'/style.css' );
$script	= file_get_contents( dirname( __FILE__ ).'/script.js' );
print( require_once( dirname( __FILE__ ).'/view.phpt' ) );
